<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!doctype html>
<html>
<head>
<title>支付网关类型</title>
<%@ include file="../../common/base.jsp" %>
</head>

<body id="body">
<!--head-->
<div id="head">
	<%@ include file="../../common/head.jsp" %>
</div>
<!--head end-->
<!--container-->
<div id="container">
	<div id="pageId" style="display: none;">05-05-01</div>
		<!--sidebar-->
		<%@ include file="../../common/menu.jsp" %>
	    <!--sidebar-->
    <!--main-->
    <div class="main">
    	<div class="location" style="background-position:22px -149px;">
        	系统配置<span>&gt;</span>收银台管理<span>&gt;</span>支付网关类型
        </div>
        <!--content-->
        <div class="content">
            <button type="button" class="btn btn_add" style="float: right;margin-top:0px;" onClick="showAdd();">添加</button>
            <div id="tableResult">
            	<table class="table_type1">
	                <thead>
	                    <tr>
	                        <th>序号</th><th>支付网关类型</th><!-- <th>权重</th> --><th>操作</th>
	                    </tr>
	                </thead>
	                <tbody id="bodyResult">
	                </tbody>
	            </table>
            </div>
            
            <div class="page">
                	<div class="itemNum" >
		                    	显示：<select id="selItem">
		                    			<option selected="selected" id="20">20</option>
		                    			<option id="30">30</option>
		                    			<option id="40">40</option>
		                    			<option id="50">50</option>
		                    		</select>条，共 <a id="totalCount" onClick="javascript:void(0);" ></a> 条
		                    </div>
                    <ul class="pagination" id="pageCur"></ul>
                </div>
        </div>
        <!--content-->
        <!--foot-->
        <div id="foot">
        	<p>北京掌中彩信息科技有限公司  提供技术支持</p>
        </div>
        <!--foot-->
    </div>
    <!--main-->
</div>
<!--container-->
<!--遮罩层-->
<div id="mask" class="pop"></div>
<!--遮罩层-->
<!--弹出框1-->
<div id="popBox" style="width:400px; margin-left:-200px;" class="pop">
	<h2>添加</h2>
    <a href="javascript:;" class="close" onClick="$(this).parent('#popBox').hide(); $('#mask').hide()"></a>
    <div class="pop_content">
		<ul class="inputInfoList3">
        	<li>
            	<label>支付网关类型名称</label>
                <input type="text" onFocus="this.style.border = '1px solid #2A7CCF'" class="text" id="paychannelTypeName" onBlur="paychannelTypeNameValide(this); this.style.border = '1px solid #D5D5D5'">
                <span class='red'>*</span>
            </li>
        	<!-- <li>
            	<label>权重</label>
                <input type="text" onFocus="this.style.border = '1px solid #2A7CCF'" class="text" id="weight" onBlur="weightValide(this); this.style.border = '1px solid #D5D5D5'">
                <span class='red'>*</span>
            </li> -->
        </ul>
    </div>
    <div class="pop_button">
    	<a href="javascript:void(0);" id="add">添加</a>
    </div>
</div>
<!--弹出框1-->

<script src="${pageContext.request.contextPath}/static/js/basic.js"></script>
<script type="text/javascript">

function showAdd(){
	$(".s_tips,.e_tips,.zhu_shi_1").each(function(i,e){
		$(e).remove();
	});
	$(".pop").show();
}

function paychannelTypeNameValide(e){
	return regValide(e, /^[\u4E00-\u9FA5a-zA-Z]{2,10}$/, "输入错误，由2-10位数字、字母或汉字组成！", true);
}

/* function weightValide(e){
	return regValide(e, /^(?!0)\d{1,2}$/, "输入错误，由1-2位数字组成！", true);
} */

//加载ajax请求
function loadResult(page,numPerPage){
	loadResultPerfect(page,numPerPage,"cashierManager/queryPayChannelTypeList","");
}

// 加载ajax返回结果
function loadTableResult(data){
	var jo = data.json;
	totalCount = data.totalCount;
	if(jo != '' && jo != null){
		for (var i = 0; i < jo.length; i++) {
			var content = "<tr>"+
	                    	"<td>"+(i+1)+"</td><td>"+jo[i].PAYCHANNEL_TYPE_NAME+"</td><td><a href='javascript:del("+jo[i].PAYCHANNEL_TYPE+");'>删除</a></td>"+
	                      "</tr>";
	        $("#bodyResult").append(content);
	    }
	}
}


//表格排序表头样式
$(document).ready(function(e) {
	$(".pop").hide();
	loadResult(1,$("#selItem").val());
	$("#add").mousedown(
        function (e) {
            setTimeout("add()", 100);
        });
});

function add(){

	if (!paychannelTypeNameValide($("#paychannelTypeName"))) {
		return;
	}
	$.ajax({
		   type: "POST",
		   url: "${pageContext.request.contextPath}/cashierManager/addPayChannelType",
		   dataType:"json",
		   data: {
		   		paychannelTypeName:$("#paychannelTypeName").val()
		   },
		   success: function(data){
			    if (data.errorCode==0){
					$(".pop").hide();
					$("#paychannelTypeName").val("");
					$("#weight").val("");
			    }
				prompt.alert(data.msg,function(){
					if (data.errorCode==0) {
						loadResult(1,$("#selItem").val());
					}
				});
		   }
   	});
}

function del(payChannelType){
	prompt.confirm("您确定要删除吗？",function(){
		$.ajax({
			   type: "POST",
			   url: "${pageContext.request.contextPath}/cashierManager/delPayChannelType",
			   dataType:"json",
			   data: {
			   		payChannelType:payChannelType
			   },
			   success: function(data){
					prompt.alert(data.msg,function(){
						if (data.errorCode==0) {
							loadResult(1,$("#selItem").val());
						}
					});
			   }
	   	});
	});
}

</script>
</body>
</html>